<?php

namespace Modules\Common\Repository\Options;

use Modules\Enroll\Models\MemSchedule;

class EnrollYears implements OptionInterface
{
    public function get(): array
    {
        $years = MemSchedule::select('mem_year')
            ->distinct()
            ->orderBy('mem_year', 'desc')
            ->pluck('mem_year')
            ->toArray();

        $options = collect($years)->map(function ($year) {
            return [
                'label' => $year . '年',
                'value' => $year
            ];
        })->toArray();

        // 添加"全部"选项到开头
        array_unshift($options, ['label' => '全部', 'value' => '']);

        return $options;
    }
} 